$(function() {
    var n;
    var w;
    var g;
    var id;
    var stime;
    var page=1;
    var allpage;
    var otab = $('table');
    var ischecked=0;
    var beacc=false;
    var stval='全部';
    var nowval='全部';
    var stva12=$('#state').text();
    var secharr=[];
    var reg={
        tel:/^1[3-9]\d{9}$/,
        cnName:/^[\u4e00-\u9fa5]{2,6}$/,
        email:/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/
    };
    // var stufflist = [
    //     { "number":"21001","name": "肖涵尹1", "tel": "12345678910", "email": "12345678910@qq.com", "textarea": "222","sex":"女","dro":"保卫科","pos":"保安","mormsg":"美丽又动人的反派角色","stime":"Thu Nov 14 2019 18:06:12 GMT+0800 (中国标准时间)"},
    //     { "number":"21002","name": "肖涵尹2", "tel": "12345678910", "email": "12345678910@qq.com", "textarea": "222","sex":"女","dro":"保卫科","pos":"保安","mormsg":"美丽又动人的反派角色","stime":"Thu Nov 14 2019 18:06:12 GMT+0800 (中国标准时间)"},
    //     { "number":"21003","name": "肖涵尹3", "tel": "12345678910", "email": "12345678910@qq.com", "textarea": "222","sex":"女","dro":"保卫科","pos":"保安","mormsg":"美丽又动人的反派角色","stime":"Thu Nov 14 2019 18:06:12 GMT+0800 (中国标准时间)"},
    //     { "number":"21004","name": "肖涵尹4", "tel": "12345678910", "email": "12345678910@qq.com", "textarea": "222","sex":"女","dro":"保卫科","pos":"保安","mormsg":"美丽又动人的反派角色","stime":"Thu Nov 14 2019 18:06:12 GMT+0800 (中国标准时间)"},
    //     { "number":"21004","name": "肖涵尹5", "tel": "12345678910", "email": "12345678910@qq.com", "textarea": "222","sex":"女","dro":"膳食部","pos":"保安","mormsg":"美丽又动人的反派角色","stime":"Thu Nov 14 2019 18:06:12 GMT+0800 (中国标准时间)"},
    //
    // ]
    // rander();
    var arr=JSON.parse(localStorage.getItem('data')) || [];
    var stufflist=JSON.parse(localStorage.getItem('stfdata')) || [];
    stunum=localStorage.getItem('stnum') || 1;
        rander();
    var thispow=localStorage.getItem('thispow');

    if(thispow=='普通'||thispow=='高级'){
        $('#add-pel').css('display','none')
        $('.del-btn').css('display','none')
        $('.bottom-btn').css('display','none')
        $('#changestf').css('display','none')
    }

    //部门下拉列表

    $('.dro-list').html('');
    for(var d=0;d<arr.length;d++){
        $('.dro-list').append(' <li><a href="#">'+arr[d].bmnr+'</a></li>')
    }
    $('#sc-dro-ul').append('<li><a href="#">全部</a></li>')
    //职位下拉列表

    $('.dro-list').on('click','li',function () {
        $('.pos-list').html('');
        for(var k=0;k<arr.length;k++){
            if(arr[k].bmnr==$(this).text()){
                for(var h=0;h<arr[k].posarr.length;h++){
                    $('.pos-list').append('<li><a href="#">'+arr[k].posarr[h].posName+'</a></li>');
                }
            }
        }
    })

    //职位委托
    $('.pos-list').on('click','li',function () {
        $('#pos').html($(this).text()+'<span class="caret"></span>');
        $('#stpos').html($(this).text()+'<span class="caret"></span>');
    })
    //删除获取n
    otab.on('click','.del-btn',function () {
       w = parseInt($(this).parent().siblings('.id').text());
    })
    // 删除员工
   $('.del-stf').click(function () {
       for(var h=0;h<stufflist.length;h++){
           if(stufflist[h].id==w){
               stufflist.splice(h,1);
           }
       }
       sechstf();
   })

   //下拉列表选择更改
    $('.choose-sex li').click(function () {
        $('#sex').html($(this).text()+'<span class="caret"></span>');
        $('#stsex').html($(this).text()+'<span class="caret"></span>');
    })
    $('.choose-dro li').click(function () {
        $('#dro').html($(this).text()+'<span class="caret"></span>');
        $('#stdro').html($(this).text()+'<span class="caret"></span>');
        $('#sech-dro').html($(this).text()+'<span class="caret"></span>')


    })
    $('.choose-pos li').click(function () {
        $('#pos').html($(this).text()+'<span class="caret"></span>');
        $('.pos').html($(this).text()+'<span class="caret"></span>');
        $('.stpos').html($(this).text()+'<span class="caret"></span>');
        $('#stpos').html($(this).text()+'<span class="caret"></span>');
    })
    $('.choose-sta li').click(function () {
        $('#state').html($(this).text()+'<span class="caret"></span>');

    })
   //下拉列表更换
    $('.keep-self').click(function () {
        $('.choose-pos div').css('display','none');
        $('.dropdown1').css('display','block');
    })
    $('.teach').click(function () {
        $('.choose-pos div').css('display','none');
        $('.dropdown2').css('display','block');
    })
    $('.sos').click(function () {
        $('.choose-pos div').css('display','none');
        $('.dropdown3').css('display','block');
    })
    $('.for-eat').click(function () {
        $('.choose-pos div').css('display','none');
        $('.dropdown4').css('display','block');
    })
    $('.money').click(function () {
        $('.choose-pos div').css('display','none');
        $('.dropdown5').css('display','block');
    })
    $('.for-more').click(function () {
        $('.choose-pos div').css('display','none');
        $('.dropdown6').css('display','block');
    })

    //正则判断
    function testTel(){
        if(reg.tel.test($('#tel').val())){
            $('#tel').css('border-color','green')
            return true;
        }
        else {
            $('#tel').css('border-color','red');
            return false;
        }

    }
    $('#tel').blur(function () {
        testTel()
    })

    function testName(){
        if(reg.cnName.test($('#name').val())){
            $('#name').css('border-color','green');
            return true;
        }
        else {
            $('#name').css('border-color','red');
            return false;
        }
    }
    $('#name').blur(function () {
        testName()
    })

    function testEmail(){
        if(reg.email.test($('#email').val())){
            $('#email').css('border-color','green')
            return true;
        }
        else {
            $('#email').css('border-color','red');
            return false;
        }
    }

    $('#email').blur(function () {
        testEmail()
    })

    function testDro(){
        if($('#dro').text()=='部门'){
            $('#dro').css('border-color','red');
            return false;
        }
        else{
            $('#dro').css('border-color','green')
            return true;
        }


    }

    function testPos(){
        if($('#pos').text()=='职位'){
            $('#pos').css('border-color','red');
            return false;
        }
        else{
            $('#pos').css('border-color','green')
            return true;
        }


    }


    // testName()&&testTel()&&testEmail()

    // 增加员工
    $('#add-pel').click(function () {
        $('#dro').html('部门<span class="caret"></span>');
        $('#pos').html('职位<span class="caret"></span>')
    })
    $('#add-new').click(function () {
        var ishad=false;
                for(var k=0;k<stufflist.length;k++){
                if(stufflist[k].tel==$('#tel').val()&&stufflist[k].name==$('#name').val()){
                        alert('该人已存在')
                        ishad=true;
                    }
                    else if(stufflist[k].tel==$('#tel').val()||stufflist[k].email==$('#email').val()){
                        alert('该联系方式已存在');
                        ishad=true;
                    }

                }
        var oDate=new Date();
        if(testName()&&testTel()&&testEmail()&&testDro()&&testPos()&&!ishad){
            var stuffData = {
                name:$('#name').val(),
                tel:$('#tel').val(),
                email:$('#email').val(),
                mormsg:$('#mor-msg').val(),
                sex:$('#sex').text(),
                dro:$('#dro').text(),
                pos:$('#pos').text(),
                state:'在校',
                id:21000+parseInt(stunum),
                stime:oDate,
                is_stay:true,




            };
            stufflist.push(stuffData);
            $('#name').val('');
            $('#tel').val('');
            $('#email').val('');
            $('#mor-msg').val('');
            $('#sex').html('选择<span class="caret"></span>');
            $('#dro').html('部门<span class="caret"></span>');
            $('#pos').html('职位<span class="caret"></span>');
            $('.pos').html('职位<span class="caret"></span>');
            $('#sech-dro').html('部门<span class="caret"></span>');
            $('#state').html('状态<span class="caret"></span>');
            $('#tel').css('border-color','#ccc');
            $('#name').css('border-color','#ccc');
            $('#email').css('border-color','#ccc');
            $('#myModal2').css('display','none');
            $('.modal-backdrop').css('display','none');

        }
       stunum++;
        rander()

    });

    //查看员工信息
    otab.on('click', '.look-stf', function () {
        g = parseInt($(this).parent().siblings('.id').text());
        // n = (page-1)*5+g;
        for(var n=0;n<stufflist.length;n++){
            if(stufflist[n].id==g){
                $('#stname').val(stufflist[n].name);
                $('#sttel').val(stufflist[n].tel);
                $('#stemail').val(stufflist[n].email);
                $('#stmsg').val(stufflist[n].mormsg);
                $('#stsex').html(stufflist[n].sex+'<span class="caret"></span>');
                $('#stdro').html(stufflist[n].dro+'<span class="caret"></span>');
                $('#stpos').html(stufflist[n].pos+'<span class="caret"></span>');
                $('#sttime').val(stufflist[n].stime);
                id=stufflist[n].id;
                stime=stufflist[n].stime;
            }
        }

    });

    //修改员工信息
    $('.re-stf').click( function () {
    for(var n=0;n<stufflist.length;n++){
        if(stufflist[n].id==g){
            stufflist[n].name=$('#stname').val();
            stufflist[n].tel=$('#sttel').val();
            stufflist[n].email=$('#stemail').val();
            stufflist[n].mormsg=$('#stmsg').val();
            stufflist[n].sex=$('#stsex').text();
            stufflist[n].dro=$('#stdro').text();
            stufflist[n].pos=$('#stpos').text();
        }
    }

        // stufflist.splice(n,1,{
        //     name:$('#stname').val(),
        //     tel:$('#sttel').val(),
        //     email:$('#stemail').val(),
        //     mormsg:$('#stmsg').val(),
        //     sex:$('#stsex').text(),
        //     dro:$('#stdro').text(),
        //     pos:$('#stpos').text(),
        //     id:id,
        //     stime:stime,
        //     is_stay:true
        // })
        // $('#sech-dro').html('部门 <span class="caret"></span>');
       sechstf();
      });


    //全选
    $("#chek-all").on("click",function(){
        if(ischecked==0){
            $("input[name='Checkbox']").prop("checked", true);
            ischecked=1;
        }else{
            $("input[name='Checkbox']").prop("checked", false);
            ischecked=0;
        }

    });
    //删除多个
    $('.del-all').click(function () {
       var chek=$("input[name='Checkbox']");
       for(var f=chek.length-1;f>=0;f--){
           if(chek[f].checked==true){
               var j=parseInt($('.id').eq(f).text());
               for(var n=0;n<stufflist.length;n++){
                   if(stufflist[n].id==j){
                       stufflist.splice(n,1);
                   }
               }
           }

       }
        $('.chek-del').css('display','none');
        $('.modal-backdrop').css('display','none');
       rander();
    })


    //上一页
    $('.pagination').on('click','#per-page',function () {
       if(page>1){
           page--;
           rander11();
           sechstf()
       }
    })
    //下一页
   $('.pagination').on('click','#next-page',function () {
     if(page<allpage){
         page++;
         rander11();
         sechstf()
     }else{
         page=allpage;
     }
   })
    //页码
    $('.pagination').on('click','.cha-page',function () {

       page=$(this).text();
       rander11();
       sechstf();
       secharr=[];
    })


    //查询
    $('#search-stuff').click(function () {
        if($('#sec-name').val()==''){
            nowval=$('#sech-dro').text();
            sechstf();
            secharr=[];
        }
        if($('#sec-name').val()!=''&&$('#sech-dro').text()=='全部'){
            secName();
            secharr=[];
        }
        if($('#sec-name').val()!=''&&$('#sech-dro').text()!='全部'){
           secBot();
           secharr=[];
        }
    })


    function sechstf() {
        if($('#sech-dro').text()!=stval&&$('#state').text()==stva12){
            for(var s=0;s<stufflist.length;s++){
                if(stufflist[s].dro==$('#sech-dro').text()){
                    secharr.push(stufflist[s]);
                }
            }
            rander2()

        }

        if($('#state').text()!=stva12&&$('#sech-dro').text()==stval){
            for(var s=0;s<stufflist.length;s++) {
                if (stufflist[s].state== $('#state').text()) {
                    secharr.push(stufflist[s]);
                }
            }
            rander2()

        }

        if($('#sech-dro').text()!=stval&&$('#state').text()!=stva12){
            for(var s=0;s<stufflist.length;s++) {
                if (stufflist[s].state== $('#state').text()&&stufflist[s].dro==$('#sech-dro').text()) {
                    secharr.push(stufflist[s]);
                }
                rander2()
            }
        }

        if($('#sech-dro').text()==stval&&$('#state').text()==stva12){
            rander()
        }
    }

    function secName() {
        for(var d=0;d<stufflist.length;d++){
            if(stufflist[d].name==$('#sec-name').val()){
                secharr.push(stufflist[d]);
            }
        }
        rander2()

        secharr=[];
    }

    function secBot() {
        for(var g=0;g<stufflist.length;g++){
            if(stufflist[g].name==$('#sec-name').val()&&stufflist[g].dro==$('#sech-dro').text()){
                secharr.push(stufflist[g]);

            }
        }
        rander2()

    }
    //渲染数据
    function rander() {
        otab.find('tbody').html('')
        for (var i= (page-1)*5; i < page*5; i++) {
            if(stufflist[i]){
                otab.append('<tr> \n' +
                    '\t\t\t\t\t           <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <div class="mui-input-row mui-checkbox">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  \t<input name="Checkbox" type="checkbox" class="chekk">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  </div>  \n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td class="id">'+stufflist[i].id+ '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].name + '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].sex+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].dro+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].pos+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].tel + '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>在校</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <button type="button" class="btn btn-primary cg-col-btn no-bor-btn look-stf" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-search"></span></button>\n' +
                    '\t\t\t\t\t\t\t\t\t      <button type="button" class="btn btn-danger cg-col-btn no-bor-btn del-btn"   data-toggle="modal" data-target=".bs-example-modal-sm"><span class="glyphicon glyphicon-trash"></span></button>\n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  </tr>')
            }
            else {
                otab.append('<tr> \n' +
                    '\t\t\t\t\t           <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <div class="mui-input-row mui-checkbox">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  </div>  \n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>空</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  </tr>')
            }

            $('#sech-dro').html(stval+'<span class="caret"></span>');
            $('#state').html(stva12+'<span class="caret"></span>');
        }
       allpage=Math.ceil(stufflist.length/5);
        $('.pagenum').html('');
         $('.pagenum').append('<li id="per-page">\n' +
             '\t\t\t\t\t\t      <a href="#" aria-label="Previous">\n' +
             '\t\t\t\t\t\t        <span aria-hidden="true">&laquo;</span>\n' +
             '\t\t\t\t\t\t      </a>\n' +
             '\t\t\t\t\t\t    </li>')
      for(var p=1;p<=allpage;p++){
          $('.pagenum').append('<li class="cha-page"><a href="#">'+p+'</a></li>')
      }
        $('.pagenum').append('<li id="next-page">\n' +
            '\t\t\t\t\t\t      <a href="#" aria-label="Next">\n' +
            '\t\t\t\t\t\t        <span aria-hidden="true">&raquo;</span>\n' +
            '\t\t\t\t\t\t      </a>\n' +
            '\t\t\t\t\t\t    </li>')

        if(thispow=='普通'||thispow=='高级'){
            $('#add-pel').css('display','none')
            $('.del-btn').css('display','none')
            $('.bottom-btn').css('display','none')
            $('#changestf').css('display','none')
        }

        $('.cha-page').removeClass('active');
        $('.cha-page').eq(page-1).addClass('active');
        localStorage.setItem('stfdata', JSON.stringify(stufflist));
      localStorage.setItem('stnum',stunum)
    }

    function rander11() {
        otab.find('tbody').html('')
        for (var i= (page-1)*5; i < page*5; i++) {
            if(stufflist[i]){
                otab.append('<tr> \n' +
                    '\t\t\t\t\t           <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <div class="mui-input-row mui-checkbox">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  \t<input name="Checkbox" type="checkbox" class="chekk">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  </div>  \n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td class="id">'+stufflist[i].id+ '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].name + '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].sex+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].dro+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].pos+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+stufflist[i].tel + '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>在校</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <button type="button" class="btn btn-primary cg-col-btn no-bor-btn look-stf" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-search"></span></button>\n' +
                    '\t\t\t\t\t\t\t\t\t      <button type="button" class="btn btn-danger cg-col-btn no-bor-btn del-btn"   data-toggle="modal" data-target=".bs-example-modal-sm"><span class="glyphicon glyphicon-trash"></span></button>\n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  </tr>')
            }
            else {
                otab.append('<tr> \n' +
                    '\t\t\t\t\t           <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <div class="mui-input-row mui-checkbox">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  </div>  \n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>空</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  </tr>')
            }


            $('#sech-dro').html(nowval+'<span class="caret"></span>');
            $('#state').html(stva12+'<span class="caret"></span>');
        }


        if(thispow=='普通'||thispow=='高级'){
            $('#add-pel').css('display','none')
            $('.del-btn').css('display','none')
            $('.bottom-btn').css('display','none')
            $('#changestf').css('display','none')
        }

        $('.cha-page').removeClass('active');
        $('.cha-page').eq(page-1).addClass('active');
        localStorage.setItem('stfdata', JSON.stringify(stufflist));
        localStorage.setItem('stnum',stunum)
    }

    //数据渲染2
    function rander2() {
        otab.find('tbody').html('')
        for (var i= (page-1)*5; i < page*5; i++) {
            if(secharr[i]){
                otab.append('<tr> \n' +
                    '\t\t\t\t\t           <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <div class="mui-input-row mui-checkbox">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  \t<input name="Checkbox" type="checkbox" class="chekk">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  </div>  \n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td class="id">' +secharr[i].id+ '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>' +secharr[i].name + '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+secharr[i].sex+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+secharr[i].dro+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>'+secharr[i].pos+'</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>' +secharr[i].tel + '</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>在校</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <button type="button" class="btn btn-primary cg-col-btn no-bor-btn look-stf" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-search"></span></button>\n' +
                    '\t\t\t\t\t\t\t\t\t      <button type="button" class="btn btn-danger cg-col-btn no-bor-btn del-btn" data-toggle="modal" data-target=".bs-example-modal-sm" ><span class="glyphicon glyphicon-trash"></span></button>\n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  </tr>')
            }
            else {
                otab.append('<tr> \n' +
                    '\t\t\t\t\t           <td>\n' +
                    '\t\t\t\t\t\t\t\t\t\t  <div class="mui-input-row mui-checkbox">\n' +
                    '\t\t\t\t\t\t\t\t\t\t  </div>  \n' +
                    '\t\t\t\t\t\t\t\t\t  </td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td>空</td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  \t\t\t\t  <td></td>\n' +
                    '\t\t\t\t\t  </tr>')
            }
        }
        allpage=Math.ceil(secharr.length/5);
        $('.pagenum').html('');
        $('.pagenum').append('<li id="per-page">\n' +
            '\t\t\t\t\t\t      <a href="#" aria-label="Previous">\n' +
            '\t\t\t\t\t\t        <span aria-hidden="true">&laquo;</span>\n' +
            '\t\t\t\t\t\t      </a>\n' +
            '\t\t\t\t\t\t    </li>')
        for(var p=1;p<=allpage;p++){
            $('.pagenum').append('<li class="cha-page"><a href="#" >'+p+'</a></li>')
        }
        $('.pagenum').append('<li id="next-page">\n' +
            '\t\t\t\t\t\t      <a href="#" aria-label="Next">\n' +
            '\t\t\t\t\t\t        <span aria-hidden="true">&raquo;</span>\n' +
            '\t\t\t\t\t\t      </a>\n' +
            '\t\t\t\t\t\t    </li>')


        if(thispow=='普通'||thispow=='高级'){
            $('#add-pel').css('display','none')
            $('.del-btn').css('display','none')
            $('.bottom-btn').css('display','none')
            $('#changestf').css('display','none')
        }

        $('.cha-page').removeClass('active');
        $('.cha-page').eq(page-1).addClass('active');
        // localStorage.setItem('stfdata', JSON.stringify(stufflist));
        localStorage.setItem('stfdata', JSON.stringify(stufflist));
        localStorage.setItem('stnum',stunum)
    }

})
